<?php
namespace app\modules\admin\controllers;

use Yii;
use yii\helpers\Url;

/**
 * Admin模块Controller基类
 *
 * Class BaseController
 * @package app\modules\admin\controllers
 */
class BaseController extends \app\controllers\BaseController
{
    public $layout = 'main'; // @app/themes/basic/modules/admin/views/layouts/main.php
    /* @var $manager false|\app\models\Manager|\yii\web\User */
    protected $manager = false;

    /**
     * @inheritdoc
     */
    public function beforeAction($action)
    {
        $this->manager = Yii::$app->manager;
        // 判断登录状态
        if ($this->manager->isGuest) {
            $this->manager->setReturnUrl(Url::current());
            $this->redirect(['/admin/login']);
            return false;
        }
        return parent::beforeAction($action);
    }
}
